<template>
  <div>
    <el-breadcrumb separator-class='el-icon-arrow-right'>
      <el-breadcrumb-item v-bind:to='{ path: "/" }'>首页</el-breadcrumb-item>
      <el-breadcrumb-item>新闻管理</el-breadcrumb-item>
      <el-breadcrumb-item>查看新闻资讯详情信息</el-breadcrumb-item>
    </el-breadcrumb>
    <div class='dict-main'>
      <el-tabs v-model='activeName' class='title-top'>
        <el-tab-pane label='查看新闻资讯详情信息' name='first'>
          <div class='main-module charger'>
            <el-row class='posre'>
              <el-col :span='12' class='text-right search-top'>
                <el-button size='small' type="primary" icon="el-icon-edit"  @click='imageTextEdit()'> 修改
                </el-button>
                <el-button size='small' type='warning' icon='el-icon-back' @click='backToList()'>返回</el-button>
              </el-col>
            </el-row>
            <div>
              <el-row :gutter="20">
                <el-col :span="14" :offset="2">
                  <el-form :model="addForm" :rules="rules" ref="addForm" label-width="100px" label-suffix=":">
                    <el-form-item label="标题名称" prop="title">
                      <span style="margin-left: 30px;">{{addForm.title}}</span>
                    </el-form-item>
                    <el-form-item label="副标题名称" prop="subTitle">
                      <span style="margin-left: 30px;">{{addForm.subTitle}}</span>
                    </el-form-item>
                    <el-form-item label="阅读量" prop="readNum">
                      <span style="margin-left: 30px;">{{addForm.readNum}}次</span>
                    </el-form-item>
                    <el-form-item label="发布时间" prop="publishTime">
                      <span style="margin-left: 30px;">{{addForm.publishTime}}</span>
                    </el-form-item>
                    <el-form-item label="Banner图">
                      <span v-if="addForm.bannerImage!=''" style="margin-left: 30px;">
                        <img :src="addForm.showBannerImage" width="200px" height="250px"/>
                      </span>
                      <span v-else style="margin-left: 30px;">暂未上传Banner图</span>
                    </el-form-item>
                    <el-form-item label="封面图">
                      <span style="margin-left: 30px;" v-if="addForm.coverImage!=''">
                        <img  :src="addForm.showCoverImage" width="200px" height="250px"/>
                      </span>
                      <span v-else style="margin-left: 30px;">暂未上传封面图</span>
                    </el-form-item>
                    <el-form-item label="发布时间" prop="publishTime">
                      <span style="margin-left: 30px;">{{addForm.publishTime}}</span>
                    </el-form-item>
                    <el-form-item label="新闻内容" prop="content" style="margin-bottom: 100px;width: 150%;">
                      <el-card class="box-card">
                      <dl v-html="addForm.content">
                        {{addForm.content}}
                      </dl>
                    </el-card>
                    </el-form-item>

                  </el-form>
                </el-col>
              </el-row>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>


  </div>
</template>

<script>
  import {
    loadImageTextDetail
  } from '@/api/imageText';
  export default {
    data() {
      return {
        activeName: 'first',
        inputVisible: false,
        addBtVisible: true,
        inputValue: '',
        editorOption: {
          modules: {
            toolbar: [
            ]
          }
        },
        addForm: {
          title: '',
          subTitle: '',
          workplace: '',
          readNum: 0,
          publishTime: '',
          content: '',
          showCoverImage: '',
          showBannerImage: ''
        }
      };
    },
    filters: {},
    methods: {
      backToList() {
        this.$router.push({
          path: '/news/imageText'
        })
      },
      loadImageTextDetail () {
        loadImageTextDetail(this.$route.params.imageTextId).then(response => {
          if (response.code !== 0) {
            this.$message({
              message: response.message,
              type: 'error'
            });
          } else {
            this.addForm = response.data;
            this.dynamicTags= response.data.label.split(';');
            this.findCitys(response.data.provinceCode);
          }
        });
      },
      imageTextEdit(){
        var imageTextId=this.addForm.id;
        this.$router.push({
          path: `/news/imageText/edit/${imageTextId}`
        })
      }
    },
    watch: {
    },
    created: function () {
      this.loadImageTextDetail();
    }
  };
</script>

